﻿@{
    Layout = null;
    HttpCookie cookie = Request.Cookies["user"];
}


<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ModifyPsw</title>
    @*Easyui需要引入的文件*@
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.5/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
    <link href="~/Content/jquery-easyui-1.4.5/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/Content/jquery-easyui-1.4.5/themes/icon.css" rel="stylesheet" />
    <script src="~/Content/jquery-easyui-1.4.5/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Content/Site.js"></script>
    <script>
        $(function () {
            $('#modify').click(function () {
                var old_psw = $('#Password').val();
                var new_psw = $('#newPassword').val();
                if (old_psw == null || old_psw == "") {
                    $.messager.alert('提示', '原密码不能为空!');
                    return false;
                }
                var postData = GetWebControls("#form");
                getAjax("/User/ModifyPassword",
                    postData, function (data) {
                        if (data == 1) {
                            //此处可以优化，提示消息可更美观。
                            $.messager.alert('提示', '密码修改成功!');
                            return true;
                        }
                        else if (data == -1) {
                            $.messager.alert('提示', '原密码输入错误!');
                            $('#Password').textbox('clear');
                            $('#newPassword').textbox('clear');
                            return false;
                        }
                        else {
                          $.messager.alert('提示', '操作失败!');
                            return false;
                        }
                    });
            });
        });
    </script>
</head>
<body style="margin:0;padding:0">
    <div style="position:fixed;width:100%;height:100%">
        <div class="easyui-panel" title="修改密码" data-options="fit:true">
            <div style="padding:10px 60px 20px 60px">
                <form id="form" method="post">
                    <table cellpadding="5">
                        <tr>
                            <td>工号:</td>
                            <td><input class="easyui-textbox" type="text" id="Code" name="Code" disabled="disabled" value="@cookie.Values["Code"]" /></td>
                        </tr>
                        <tr>
                            <td>姓名:</td>
                            <td><input class="easyui-textbox" type="text" id="Name" name="Name" disabled="disabled" value="@HttpUtility.UrlDecode(cookie.Values["Name"])" /></td>
                        </tr>
                        <tr>
                            <td>账号:</td>
                            <td><input class="easyui-textbox" type="text" id="Username" name="Username" disabled="disabled" value="@HttpUtility.UrlDecode(cookie.Values["Username"])" /></td>
                        </tr>
                        <tr>
                            <td>角色:</td>
                            <td><input class="easyui-textbox" type="text" id="Role" name="Role" disabled="disabled" value="@HttpUtility.UrlDecode(cookie.Values["Role"])" /></td>
                        </tr>
                        <tr>
                            <td>部门:</td>
                            <td><input class="easyui-textbox" type="text" id="Department" name="Department" disabled="disabled" value="@HttpUtility.UrlDecode(cookie.Values["Department"])" /></td>
                        </tr>
                        <tr>
                            <td>原密码:</td>
                            <td><input class="easyui-textbox" type="password" id="Password" name="Password" /></td>
                        </tr>
                        <tr>
                            <td>新密码:</td>
                            <td><input class="easyui-textbox" type="password" id="newPassword" name="newPassword" /></td>
                        </tr>
                    </table>
                </form>
                <div style="padding:5px 0 0 120px">
                    <a href="javascript:void(0)" class="easyui-linkbutton" id="modify">修改</a>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
